// boost_type_any.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
#include "boost/any.hpp"
#include "vector"

using namespace std;
using namespace boost;

typedef std::vector<boost::any> many;


int _tmain(int argc, _TCHAR* argv[])
{
	many vtAny;

	vtAny.push_back(3);
	vtAny.push_back(_T("String"));
	vtAny.push_back(4.55);

	for(int i=0; i<vtAny.size(); ++i)
	{
		cout << vtAny.at(i).type().name() << endl;
		try
		{
			//string str = any_cast<string>(vtAny.at(i));
			//cout << str << endl;
			int iResult = any_cast<int>(vtAny.at(i));
			cout << iResult << endl;
		}
		catch (boost::bad_any_cast  &  ex)
		{
			cout << "cast error: " << ex.what() << endl;
		}
	}



	return 0;
}

